SG Window IsgMessageSink
Message Method

©1998 by Stinga

IsgMessageSink      Constants     Error Codes
Description

Called when new message arrives.

Syntax

Private Sub IsgMessageSink_Message(ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long, ByRef result As Long)

Part Description
IsgMessageSink Name of the implemented interface.
msg Received message code.
wParam Message specific data.
lParam Message specific data.
result Message result code.
Remarks

You implement IsgMessageSink interface and it's Message method when you want to receive messages through fast callback interface.

Values and interpretation of wParam and lParam parameters depends on received message. Please consult Win32 API documentation for more details on parameters passed with different messages.

If message is not handled in the Message method, you must call CallWindowProc method and let default window procedure handle message. How and when you are going to call it depends on what you want to accomplish. In some cases you will handle message entirely in the VB code and you will not call default window procedure at all.

Result is window procedure return value. You must update value of the result parameter according to the received message. Win32 API documentation contains info about these return values.

Example

Following example shows how to implement and use IsgMessageSink interface in the class module:

' Declare message callback interface
Implements IsgMessageSink

' Declare SGWindow object
Private mWnd As SGWindow.Window

Private Sub Class_Initialize()
   ' Crete object
   Set mWnd = New SGWindow.Window

   ' Enable messages
   mWnd.EnableMessage wm_MOUSEWHEEL

   ' Attach callback interface
   mWnd.SetMessageCallback Me
End Sub

Private Sub Class_Terminate()
   ' Destroy object
   Set mWnd = Nothing
End Sub

Private Sub IsgMessagesink_Message(ByVal msg As Long, ByVal wParam As Long, _
                    ByVal lParam As Long, ByRef result As Long)
   ' Write some useful code here ...
   Debug.Print CStr(LowWord(lParam))

   ' ... and/or call default window procedure
   result = mWnd.CallWindowProc(msg, wParam, lParam)
End Sub

' Attach this class to the window
Public Property Let hWnd(hwnd as long)
   mWnd.hWnd = hwnd
   If hwnd <> 0 then
      mWnd.Hooked = True
   Else
      mWnd.Hooked = False
   End If
End Property